package com.linjing.item.controller;

import com.linjing.item.model.ItemBo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.net.InetAddress;

/**
 * @author 仇冬林
 * @date 2022/5/6
 */

@Slf4j
@RestController
@RequestMapping("/item")
public class ItemController {

    @Value("${server.port}")
    private String port;

    
    @RequestMapping("/addItem")
    public String addItem(){

        return "添加成功";
    }

    @RequestMapping("/get/{id}")
    public ItemBo getItem(@PathVariable("id") Long id){
        log.info("item id: {}", id);
        ItemBo item = new ItemBo();
        item.setId(id);
        item.setItemCode("itemCode:" + id);
        item.setItemName("itemName:" + id);
        return item;
    }

    @RequestMapping("/query")
    public ItemBo queryItem(Long id){
        log.info("item id: {}", id);
        ItemBo item = new ItemBo();
        item.setId(id);
        item.setItemCode("itemCode:" + id);
        item.setItemName("itemName:" + id);
        return item;
    }

    @RequestMapping("/load")
    public String testLoadBalance(){
        return port;
    }
}
